package com.treasure.mall.biz.service.core.wxtemplate.impl;

import com.treasure.mall.biz.dto.wxtemplate.SubscribeSaveDTO;
import com.treasure.mall.biz.entity.user.UserPO;
import com.treasure.mall.biz.entity.wxtemplate.SubscribeUserPO;
import com.treasure.mall.biz.repository.wxtemplate.SubscribeUserRepository;
import com.treasure.mall.biz.service.core.wxtemplate.SubscribeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 *
 * <p>
 * +---------------------------------------------------------
 * * @package: com.treasure.mall.biz.service.core.wxtemplate.impl
 * * @author: guomw (guomwchen@foxmail.com)
 * * @date: 2020/8/4 10:04 上午
 * * @since: V1.0.0
 * +---------------------------------------------------------
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 * 
 */
@Service
public class SubscribeUserServiceImpl implements SubscribeUserService {

    @Autowired
    private SubscribeUserRepository subscribeUserRepository;

    @Override
    public void pushSubscribe(SubscribeSaveDTO dto, UserPO user) {
        SubscribeUserPO subscribeUserPO = new SubscribeUserPO();
        subscribeUserPO.setSubscribeUser(user);
        subscribeUserPO.setSubscribeOpenId(dto.getOpenId());
        subscribeUserPO.setTempId(dto.getTempId());
        subscribeUserPO.setTemplateMessageType(dto.getTemplateMessageType());
        subscribeUserPO.setCreateTime(LocalDateTime.now());
        subscribeUserRepository.save(subscribeUserPO);
    }
}
